package com.itheima.web.controller.cargo;

import com.itheima.web.controller.BaseController;
import net.sf.jasperreports.engine.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.HashMap;

@Controller
@RequestMapping("/cargo/export")
public class PdfController extends BaseController {
    @RequestMapping("/exportPdf")
    public void exportPdf() throws JRException, IOException {
        String path = session.getServletContext().getRealPath("/")+"/jasper/export.jasper";
        JasperPrint jp = JasperFillManager.fillReport(path, new HashMap<>(), new JREmptyDataSource());
        JasperExportManager.exportReportToPdfStream(jp,response.getOutputStream());
    }

}
